NHibernate 4.x Cookbook - Second Edition by Liljas Gunnar & Zaytsev Alexander & Dentler Jason
Author:Liljas, Gunnar & Zaytsev, Alexander & Dentler, Jason [Liljas, Gunnar]
Language: eng
Format: azw3
Publisher: Packt Publishing
Published: 2017-01-30T16:00:00+00:00
Run the application and start the QueryBySql recipe.
How it works…
We won't get into the details of the SQL queries.
Eager loading with LINQ
Often, when we query for some set of entities, we also want to load some of the related entities. In this recipe, we'll show you how we can use LINQ extensions to eager load the child collections of our query results.
Getting ready
Complete the Getting Ready section at the beginning of this chapter.
How to do it…
Create a new folder named EagerLoadingWithLinq in the project.
Add a new class named Recipe to the folder:using System.Linq; using NH4CookbookHelpers.Queries; using NH4CookbookHelpers.Queries.Model; using NHibernate; using NHibernate.Linq; namespace QueryRecipes.EagerLoadingWithLinq { public class Recipe : QueryRecipe { protected override void Run(ISession session) { var book = session.Query<Book>() .Fetch(x => x.Publisher) .FirstOrDefault(); Show("Book:", book); var movies = session.Query<Movie>() .FetchMany(x => x.Actors) .ToList(); Show("Movies:", movies); } } }
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12957)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10383)
Hello! Python by Anthony Briggs(10198)
The Mikado Method by Ola Ellnestam Daniel Brolund(10107)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(10043)
Dependency Injection in .NET by Mark Seemann(9581)
Hit Refresh by Satya Nadella(9016)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8588)
The Kubernetes Operator Framework Book by Michael Dame(8377)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8179)
Robo-Advisor with Python by Aki Ranin(8131)
Practical Computer Architecture with Python and ARM by Alan Clements(8115)
Implementing Enterprise Observability for Success by Manisha Agrawal and Karun Krishnannair(8095)
Svelte with Test-Driven Development by Daniel Irvine(7986)
Building Low Latency Applications with C++ by Sourav Ghosh(7986)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7969)
Grails in Action by Glen Smith Peter Ledbrook(7942)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7904)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7900)